<?php

namespace app\api\controller\v1;

use think\Controller;
use think\Request;
use app\common\controller\BaseController;
use app\common\validate\UserValidate;
use app\common\model\User as UserModel;

class User extends BaseController
{
    // 发送验证码
    public function sendCode(){

        //验证参数
        (new UserValidate())->goCheck('sendCode');

        // 发送验证码
        (new UserModel())->sendCode();

        return self::showResCodeWithOutDate('发送成功');
    }

    // 手机号码登录
    public function phoneLogin(){

        //验证登录信息
        (new UserValidate())->goCheck('phonelogin');

        //获取token
        $token = (new UserModel())->phoneLogin();

        return self::showResCode('登陆成功',['token'=>$token]);
    }

    // 账号密码登陆
    public function login(){
        //验证登录信息
        (new UserValidate())->goCheck('login');

        //获取token
        $token = (new UserModel())->login();

        return self::showResCode('登陆成功',['token'=>$token]);
    }
}
